﻿#ifndef PST_SURFACEELECTRICFIELDMAPSIDEBARSETTINGS_H
#define PST_SURFACEELECTRICFIELDMAPSIDEBARSETTINGS_H

#include <QWidget>
#include <QScrollArea>
#include <QMouseEvent> 
#include <QListView>
#include <QListWidget>
#include <QSize>
#include <QRect>
#include <QModelIndex>
#include "InfomationGraph3DBasical.h"

QT_BEGIN_NAMESPACE
namespace Ui { class SurfaceElectricFieldMapSidebarSettings; };
class QTabWidget;
class QLineEdit;
class QComboBox;
class QListView;
class QCheckBox;
class QVBoxLayout;
class QStandardItem;
QT_END_NAMESPACE

namespace pst
{
    class SurfaceElectricFieldMapSidebarData;

    class SurfaceElectricFieldMapSidebarSettings : public QScrollArea
    {
        Q_OBJECT
    public:
        SurfaceElectricFieldMapSidebarSettings(QWidget* parent = nullptr);
        ~SurfaceElectricFieldMapSidebarSettings();

        void setMainWiondowId(int id);

        //QListWidgetItem* addCurveToList(const QString& curveName);

        QListWidgetItem* addData(InfomationGraph3DBasical* info);

        //void setSlicePositionEnum(const QList<double>& xSliceEnum,
            //const QList<double>& ySliceEnum, const QList<double>& zSliceEnum);
        void updateInfoDataAndInterfaceToUI(SurfaceElectricFieldMapSidebarData* data);

        // 设置控制面板是否可编辑
        void setControlPanelEditable(bool enable);
        void clearControlPlane();
        QListWidget* getCurveNameListWidget();

        // 设置控制面板是否为动画状态，动画状态下不可编辑
        void setControlPlaneToAnimationState(bool isAnimationState);
    private:
        void addTopTabPivotUI();
        void addDataPageUI();
        void addCurveListUI();
        void addDataOptrationUI();
        void hideComponents();

    signals:
        void signal_chosenItemsChanged(const QList<QListWidgetItem*>& itemList);
        void siganl_showHideItemActor(QListWidgetItem* item);
        void siganl_graphNameDoubleClicked(QListWidgetItem* item);
        void signal_updateActorValue(SurfaceElectricFieldMapSidebarData* data);
        void signal_deleteChosenGraphs(const QList<QListWidgetItem*>& itemList);
        void signal_getSidebarCurveDataSource(QListWidgetItem* item, QString& dataSource);
        void signal_renameCheck();//重命名结果检查

    public slots:
        void slot_curveNameClicked();
        void slot_itemCheckStateChanged(QListWidgetItem* item);
        void slot_itemDoubleClicked(QListWidgetItem* item);
        void slot_resultDataChanged(int index);
        void slot_updateProcessData();
        void slot_addCustomContextMenu(const QPoint& pos);
        void on_pushButton_FormulaEditor_clicked();
        void on_radioButton_Amplitude_clicked();     // 幅度
        void on_radioButton_Phase_clicked();         // 相位
        void on_radioButton_RealPart_clicked();      // 实部
        void on_radioButton_ImaginaryPart_clicked(); // 虚部

        void slot_renameItem();

    public: // python调用
        void pyCurveNameClicked(QList<int> selectedIndexs);
        void pyResultDataChanged(int index);
        void pyUpdateProcessData(bool isLog, bool isNormalize);
        void pyDeleteSurfaceElectricFieldMap(QString selectedIndexs);
        void pyItemCheckStateChanged(int itemIndex, bool visible);

    private:
        void connectSignalsAndSlots();
        void disconnectSignalsAndSlots();

    private:
        int m_mainWindowId;
        Ui::SurfaceElectricFieldMapSidebarSettings* ui;
        int _titleFontSize;
        QPair< InfomationGraph3DBasical*, QListWidgetItem* > m_currentChosenItem;
        QList<QPair<InfomationGraph3DBasical*, QListWidgetItem*>> m_allAddedDataList;
        SurfaceElectricFieldMapSidebarData* m_currentItemData;
        QList<FieldGraphGenerator::ArrayInformation> m_addedArrayList;

        QVector<bool> m_enableStatus;
    };

}

#endif
